package cn.karent.client.dto;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.apache.commons.lang3.StringUtils;

/**
 * @author wanshengdao
 * @date 2025/4/22
 */
@Setter
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class CookUpdateReq {

    @NotNull(message = "id不能为空")
    private Integer id;

    private String category;

    private String name;

    private String content;

    @AssertTrue(message = "category, name, content至少有一个不能为空")
    private boolean isValid() {
        return StringUtils.isNotBlank(name) || StringUtils.isNotBlank(content) || StringUtils.isNotBlank(category);
    }
}
